package com.ding.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Data
@NoArgsConstructor
@Entity							//注解为实体
@Table(name="authorities")		//映射的表
public class Authority {
	String authority;

	@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)	//多对一关系,cascade用来设置级联时期,fetch用来设置抓取策略
	@JoinColumn(name = "username")	//在本表中插入一个username外键以描述Authority和User的对应关系
	private User user;
	
	@Id					//必须有个主键
	@GeneratedValue(strategy= GenerationType.AUTO) //设置其生成策略为自动生成
    private Integer id;

	public Authority(User user,String authority) {
		this.authority=authority;
		this.user=user;
	}

	@Override
	public String toString() {
		return authority;
	}
	
}
